package sismed.gui.comando;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import sismed.negocio.fachada.Fachada;
import sismed.negocio.modelo.Paciente;

public class ComandoCarregarPacientesReceita extends ComandoGenerico {

	@Override
	public void executar(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		Fachada fachada = Fachada.getInstance();
		
		List<Paciente> lista = fachada.recuperarListaPacientes();
		
		System.out.println( lista.size());
		
		try 
		{		
			request.setAttribute("ListaPacientes", lista);
			request.getRequestDispatcher("realizarConsulta.jsp").forward(request, response);	
		} 
		catch (Exception e) 
		{
			response.sendRedirect("erro.jsp?msgerro=Erro ao recuperar mensagens.");	
		}
	}
}
